#encoding:utf-8
import os

head = '''
<!DOCTYPE html>
<html>

<head>
    <title>888666444's Music Webside</title>
</head>

<body style="margin: 0;padding: 0;font-family: 'Courier New', Courier, monospace;">
    <div style="height: 60px;padding: 15px;">
        <div style="float:left"><img src="./index.png" style="width: 100px;"></div>
        <div style="float:right">
            <p style="color:gray;font-size: small;">888666444's Music Website</p>
        </div>
    </div>
    <hr>
    <p>Artist List:</p>
    <div style="padding: 15px;min-height: 1200px;">
        <div style="display:flex;flex-wrap: wrap;">
'''
foot = '''
		</div>
    </div>
    <div>
        <footer
            style="background-color:#646464;text-align: center;height: 100px;margin-top: 62px;padding:20px;bottom:0;position: relative">
            <p style="color:white">888666444's Music Website</p>
        </footer>
    </div>
</body>

</html>
'''
file = open("index.html","w")
file.write(head)
lsdata = os.listdir("./music")
tmp = 0
for data in lsdata:
    #print(data)
    path = "./music/"+data+"/index.html"
    _str = '''
    <div style="height: 70px;width: 32%">
                <div style="float:left;width:100%;height:70px;text-align:center;display: table-cell;vertical-align: middle;background-color: #e2e2e2;">
                    <a href="'''+path+'''" style="color: black;text-decoration:none"><h3 >'''+data+'''</h3></a>
                </div>
            </div>
            <p style="background-color: white;color:white;">|</p>
    '''
    #updcmd = "python \"music/"+data+"/upd.py\""
    #print(updcmd)
    #os.system(updcmd)
    if data != "0example":
        file.write(_str)
file.write(foot)
file.close()
print("Website Updated")